import { observable, action, isObservable, computed } from 'mobx';
import Container from 'stores/models/core/nodeWithList/container';

/**
 * ContainerAtLeastOneChild
 * Project, Slider, Carousel
 */
export default class ContainerAtLeastOneChild extends Container {
  originType = 'ContainerAtLeastOneChild';

  // 删除容器时需保留最后一个
  @action remove(container) {
    if (this.list.length > 1) {
      const index = this.list.indexOf(container);
      if (index !== -1) {
        this.select(this.list[ index === 0 ? index + 1 : index - 1 ]);
        this.list.remove(container);
      }
    }
  }
}
